#ifndef UPLOADER_H
#define UPLOADER_H

#include <QObject>
#include <QString>
#include <QNetworkReply>
#include <QEventLoop>
#include <QNetworkAccessManager>

class Uploader : public QObject
{
    Q_OBJECT

public:
    Uploader();
    QString uploadImage(QString filePath);
private:
    QString resultUrl;
    QEventLoop loop;

    void uploadFile(QString filePath);
    QByteArray preparePostData(QString filePath, QString boundary);

private slots:
    void replyFinished(QNetworkReply *reply);
    void resultUrlParsed(QString url);
    void parsingUrlError(QString errorMsg);
signals:
    void error(QString errorMsg);
    void resultUrlReady(QString url);
};

#endif // UPLOADER_H
